{% load map_icons %}
<div id="location-info-container-extended">

    <div class="location-address no-border">
        <img src="{{ base_station|get_icon }}" class="location-network-icon pull-left" />
        <strong>{{ base_station.network.name }}</strong> ({{ base_station.network.code }})
        {% if base_station.station_id %}
            ID: <abbr title="Identyfikator wewnętrzny operatora">{{ base_station.station_id }}</abbr>
        {% endif %}
        {% if base_station.is_networks %}
            (<abbr title="Stacja będąca częścią NetWorks!">N!</abbr>)
        {% endif %}<br/>
        <small>
            {{ base_station.location.town }},
            {% if base_station.location_details %}
                {{ base_station.location_details }}
            {% else %}
                {{ base_station.location.adddress }}
            {% endif %}
        </small>
    </div>

    <div>
    {% for standard in base_station.get_cells_by_standard %}
        {% if standard.standard == 'GSM' or standard.standard = 'E-GSM' %}
        <table class="table table-condensed table-responsive location-info">
            <tr>
                <th colspan="4" style="border-top: none;">{{ standard.standard }}</th>
            </tr>
            <tr>
                <th>Pasmo</th>
                <th><abbr title="Local Area Code">LAC</abbr></th>
                <th><abbr title="Cell ID">CID</abbr></th>
                <th>Uwagi</th>
            </tr>
            {% for cell in standard.cells %}
            <tr {% if not cell.is_confirmed %}class="danger" title="Komórka nie potwierdzona"{% endif %}>
                <td>{{ cell.band }}</td>
                <td>{{ cell.lac }}</td>
                <td>{{ cell.cid }}</td>
                <td>{% if cell.notes %}{{ cell.notes }}{% else %}--{% endif %}</td>
            </tr>
            {% endfor %}
        </table>
        {% endif %}
        {% if standard.standard == 'UMTS' %}
        <table class="table table-condensed table-responsive location-info">
            <tr>
                <th colspan="7" style="border-top: none;">{{ standard.standard }}</th>
            </tr>
            <tr>
                <th>Pasmo</th>
                <th><abbr title="Local Area Code">LAC</abbr></th>
                <th><abbr title="Radio Network Controller">RNC</abbr></th>
                <th><abbr title="Cell ID">CID</abbr></th>
                <th><abbr title="Long Cell ID = RNC * 65536 + CID">LongCID</abbr></th>
                <th>Nośna</th>
                <th>Uwagi</th>
            </tr>
            {% for cell in standard.cells %}
            <tr {% if not cell.is_confirmed %}class="danger" title="Komórka nie potwierdzona"{% endif %}>
                <td>{{ cell.band }}</td>
                <td>{{ cell.lac }}</td>
                <td>{% if base_station.rnc == 0 %}?{% else %}{{ base_station.rnc }}{% endif %}</td>
                <td>{{ cell.cid }}</td>
                <td>{{ cell.cid_long }}</td>
                <td>{% if cell.ua_freq == 0 %}?{% else %}{{ cell.ua_freq }}{% endif %}</td>
                <td>{% if cell.notes %}{{ cell.notes }}{% else %}--{% endif %}</td>
            </tr>
            {% endfor %}
        </table>
        {% endif %}
        {% if standard.standard == 'LTE' %}
        <table class="table table-condensed table-responsive location-info">
            <tr>
                <th colspan="6" style="border-top: none;">{{ standard.standard }}</th>
            </tr>
            <tr>
                <th>Pasmo</th>
                <th><abbr title="Local Area Code">LAC</abbr></th>
                <th><abbr title="eNodeB ID">eNBID</abbr></th>
                <th><abbr title="Cell Local ID">CLID</abbr></th>
                <th><abbr title="Enhanced CID = eNBI * 256 + CLID">E-CID</abbr></th>
                <th>Uwagi</th>
            </tr>
            {% for cell in standard.cells %}
            <tr {% if not cell.is_confirmed %}class="danger" title="Komórka nie potwierdzona"{% endif %}>
                <td>{{ cell.band }}</td>
                <td>{{ cell.lac }}</td>
                <td>{% if base_station.enbi == 0 %}?{% else %}{{ base_station.enbi }}{% endif %}</td>
                <td>{{ cell.cid }}</td>
                <td>{{ cell.cid_long }}</td>
                <td>{% if cell.notes %}{{ cell.notes }}{% else %}--{% endif %}</td>
            </tr>
            {% endfor %}
        </table>
        {% endif %}
    {% endfor %}
    </div>

    {% with base_station.permissions.all as permissions %}
        {% if permissions %}
            <table class="table table-condensed table-responsive location-info">
                <tr>
                    <th colspan="6" style="border-top: none;">Powiązane pozwolenia UKE</th>
                </tr>
                <tr>
                    <th>Standard</th>
                    <th>Pasmo</th>
                    <th>Nr stacji</th>
                    <th>Nr pozwolenia</th>
                    <th><abbr title="P=pozwolenie; zmP=zmiana pozwolenia">Typ</abbr></th>
                    <th>Data ważności</th>
                </tr>
            {% for p in permissions %}
                <tr>
                    <td>{{ p.permission.standard }}</td>
                    <td>{{ p.permission.band }}</td>
                    <td>{{ p.permission.station_id }}</td>
                    <td>{{ p.permission.case_number_display }}</td>
                    <td>{{ p.permission.case_type }}</td>
                    <td>{{ p.permission.expiry_date }}</td>
                </tr>
            {% endfor %}
            </table>
        {% endif %}
    {% endwith %}
    </div>

    <div class="location-info-footer small pull-right">
        Data aktualizacji: {{ base_station.date_updated|date:"d.m.Y" }}
        {% if request.user.is_staff %}
            <br/>ID: <a href="{% url 'panel:basestation-edit-view' base_station.id %}">{{ base_station.id }}</a>
        {% endif %}
    </div>
</div>
